package com.example.park2212.merchant

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.alibaba.android.arouter.facade.annotation.Route
import com.blankj.utilcode.util.ToastUtils
import com.example.lib_base.entity.MerchatBeanItem
import com.example.lib_base.entity.ProcessingStep
import com.example.lib_base.mvvm.BaseActivity
import com.example.park2212.R
import com.example.park2212.databinding.ActivityMerchantAddBinding
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
@Route(path = "/app/merchant/MerchantAddActivity")
class MerchantAddActivity : BaseActivity<ActivityMerchantAddBinding,MerchantViewModel>() {
    override fun initView() {
        binding.merAddHead.headerTitle.setText("入驻申请")
        binding.merAddHead.headerBack.setOnClickListener {
            finish()
        }

        binding.merAddHead.headerAdd.apply {
            setOnClickListener {
                val name = binding.AddProject.text.toString()
                val user = binding.AddName.text.toString()
                val phone = binding.AddPhone.text.toString()
                val time = binding.AddTime.text.toString()
                val area = binding.AddArea.text.toString().toInt()
                val num = binding.AddNum.text.toString().toInt()
                val beanItem = MerchatBeanItem(
                    area, "RZ241109", phone, user, emptyList(), name, 2, num, time, 1,
                    arrayListOf(ProcessingStep("新建", 6, time)), "新建"
                )
                viewModel.merchantAdd(beanItem)
            }
        }
    }

    override fun initData() {
        viewModel.merchantAddSuccess.observe(this){
            ToastUtils.showLong("添加成功")
            finish()
        }
    }

}